package com.iu.web.author;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.iu.service.author.DutyService;
import com.iu.util.Tools;

/**
 * 
 * @title: 值别
 * @description: {desc}
 * @company: gdyd
 * @className: DutyController.java
 * @author: fengzt
 * @createDate: 2015年8月6日
 * @updateUser: fengzt
 * @version: 1.0
 */
@Controller
@RequestMapping("duty")
public class DutyController {
	private Logger log = Logger.getLogger(DutyController.class);
    
    @Autowired
    private DutyService dutyService;
    
    @Autowired
    private HttpServletRequest request;
    
    @Autowired
    private HttpServletResponse response;

    @RequestMapping("/index")
    public @ResponseBody String index() throws IOException{
    	 response.setCharacterEncoding("UTF-8");
         response.setContentType("text/xml");
         ServletInputStream in = request.getInputStream();
         String xmlMsg = Tools.inputStream2String(in);
         log.debug("输入消息:[" + xmlMsg + "]");
         //String xml = WeChat.processing(xmlMsg);
         
         String outMsg = "<xml>" +
        		 "<ToUserName><![CDATA[ofqq4wS-FD456uw-B_JGmPrhToTU]]></ToUserName>" +
        		 "<FromUserName><![CDATA[gh_a0070c108c03]]></FromUserName>" +
        		 "<CreateTime>" + new Date().getTime() + "</CreateTime>" +
        		 "<MsgType><![CDATA[text]]></MsgType>" +
        		 "<Content><![CDATA[ 你好 ！！ hello  ]]></Content>" +
        		 "</xml>";
         return outMsg;
    }
}
